#include <AtlasBase.h>
#include <AtlasCommon.h>
#include <AtlasClient.h>
#include <AtlasClientApp.h>

#include <stdio.h>
#include "ExLobbyDDL.h"

int main(int argc, char* argv[])
{
	Atlas::ASockIOInit();

	Atlas::CClientApp	TestApp(true);
	Atlas::CClient		TestClient(&TestApp);

	Atlas::SOCKADDR sa;
	if(argc > 1)
	{
		Atlas::STR2ADDR(argv[1], sa);	//login server port
		printf("Client Login server[%s]", argv[1]);
	}
	else
	{
		Atlas::STR2ADDR("127.0.0.1:1978", sa);	//login server port
	}
	

	TestClient.Login(sa, 1978, "123456");	

	while(TestClient.GetClientState() != Atlas::CClient::CLIENT_LOGINED) 
	{	
		if(TestClient.GetClientState() == Atlas::CClient::CLIENT_AUTH_FAILED) break;
		SwitchToThread();
	}

	if(TestClient.GetClientState()==Atlas::CClient::CLIENT_LOGINED)
	{
		printf("logined\n");
	}
	else
	{
		printf("login failed\n");
	}
	getchar();
	
	TestClient.Logout();
	Atlas::ASockIOFini();
	return 0;
}
